package com.opener.common.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * @author baboy
 */
public class Utils {
	public static Date getEndTimeOfDay(Date date){
		if(date==null){
			return null;
		}
		int hh=23;
		int mm=59;
		int ss=59;
		int ms=999;
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, hh);
		calendar.set(Calendar.MINUTE, mm);
		calendar.set(Calendar.SECOND, ss);
		calendar.set(Calendar.MILLISECOND, ms);
		Date newDate = calendar.getTime();
		return newDate;
	}

	public static Date getBeginTimeOfDay(Date date){
		if(date==null){
			return null;
		}
		int hh=0;
		int mm=0;
		int ss=0;
		int ms=0;
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, hh);
		calendar.set(Calendar.MINUTE, mm);
		calendar.set(Calendar.SECOND, ss);
		calendar.set(Calendar.MILLISECOND, ms);
		Date newDate = calendar.getTime();
		return newDate;
	}
	public static Integer parseInt(Object s){
		if (s == null){
			return null;
		}
		try {
			return Integer.parseInt(s.toString());
		}catch (Exception e){
			e.printStackTrace();
		}
		return null;
	}
}
